/**
 * Created by jiachneyu on 2018/3/14.
 */

const koa = require('koa');

const router = require('./controller');

const bodyParser = require('koa-bodyparser');

const cors = require('koa2-cors');

const statics = require('koa-static');

const path = require("path");

const history = require("koa2-connect-history-api-fallback")

const fs = require("fs");

const dev = false;

const app = new koa();

app.use(bodyParser());
// app.use(cors({}));
app.use(history())
app.use(statics(__dirname + "/dist"));
app.use(statics(__dirname + "/static"));
app.use(router());

// app.use(views(path.resolve(__dirname+ "/dist"),{ map: {html: "html"}}));

if(dev) {
    // require('./updateIp')();
    app.listen(3000);
}
else {
    app.listen(3000);
}
console.log('start');